#
# Make file to build the example applications for the DBConnect API
# Copyright (c) Johnathan Ingram 2002
#
#####################################################################

SHELL = /bin/sh

top_srcdir = @top_srcdir@
CC = @CC@
CXX = @CXX@
CPPFLAGS = @CPPFLAGS@
CFLAGS = -fPIC $(CPPFLAGS) @CFLAGS@
IFLAGS = -I../include
LFLAGS = -lstdc++ -ldl -L../lib -ldbconnect -lpthread


all: basic_select basic_transaction basic_connection driver_examples
	@echo
	@echo "Add the ./lib directory to your library path before running the examples"
	@echo "export \"LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:{DBConnectHome}/lib\""
	@echo


basic_select: basic_select.cpp
	$(CC) -c  basic_select.cpp $(CFLAGS) $(IFLAGS) -o basic_select.o
	$(CC) -o  basic_select $(CFLAGS) $(IFLAGS) basic_select.o $(LFLAGS)


basic_transaction: basic_transaction.cpp
	$(CC) -c  basic_transaction.cpp $(CFLAGS) $(IFLAGS) -o basic_transaction.o
	$(CC) -o  basic_transaction $(CFLAGS) $(IFLAGS) basic_transaction.o $(LFLAGS)


basic_connection: basic_connection.cpp
	$(CC) -c  basic_connection.cpp $(CFLAGS) $(IFLAGS) -o basic_connection.o
	$(CC) -o  basic_connection $(CFLAGS) $(IFLAGS) basic_connection.o $(LFLAGS)


driver_examples:
	(cd ./mysql && $(MAKE) all) || exit 1
	(cd ./postgresql && $(MAKE) all) || exit 1
	(cd ./msql && $(MAKE) all) || exit 1
	(cd ./ibmDB2 && $(MAKE) all) || exit 1


clean:
	rm -f ./*.o
	rm -f ./basic_select
	rm -f ./basic_transaction
	rm -f ./basic_connection
	(cd ./mysql && $(MAKE) clean) || exit 1
	(cd ./postgresql && $(MAKE) clean) || exit 1
	(cd ./msql && $(MAKE) clean) || exit 1
	(cd ./ibmDB2 && $(MAKE) clean) || exit 1

